package com.gangye;

import java.text.DecimalFormat;
import java.util.regex.Pattern;

/**
 * @Classname StringUtil
 * @Description 字符串工具类
 * @Date 2020/4/3 16:02
 * @Created by gangye
 */
public class StringUtil {
    //判断传入的字符串是否是数字
    public static boolean isNumStr(String numStr){
        Pattern pattern = Pattern.compile("[0-9]*");
        return pattern.matcher(numStr).matches();
    }

    //判断传入的字符串是否为空
    public static boolean isEmpty(String str){
        return (null==str || "".equals(str));
    }

    //四舍五入取两位小数（补零）
    public static String formatDouble(double d) {
        DecimalFormat df = new DecimalFormat("0.00");
        return df.format(d);
    }

}
